// PALib
#include <PA9.h>

// PAGfxConverter Include
#include "gfx/all_gfx.c"
#include "gfx/all_gfx.h"

// Other resources
#include "hentai.h"
#include "hh.h"
//#include "gto1.h"
//#include "gto2.h"

// Main function
int main(void)	{
	// PAlib init
	PA_Init();
	// Init the VBL, lol
	PA_InitVBL();
	// Initiate Splash, why not? im using the PAlib..
	PA_SplashBlue();
	// Initiate Text on screen 0, bg 0
	PA_InitText(1,0);
	// Initiate Sound
	PA_InitSound();
	
	// Loads palettes to the dancers, screen 0, bank 0 
	PA_LoadSpritePal(1,0,(void*)sprite0_Pal);
	PA_LoadSpritePal(0,0,(void*)sprite1_Pal);
	// Initiates 16bit bg on screen 0, bg 2
	PA_Init16bitBg(0, 2);
	// Loads a bg on screen 1, bg number is 1 , 								
	PA_EasyBgLoad (1, 2, bg0);
	// Plays .mod, from HtheB
	PA_PlayMod(hh);
	// Sets the color of text to green, unnecessary coz text wont show, and is not used anyway :P
	PA_SetTextCol(1, 0, 31, 0);
	// Prints "Hello username!"
	PA_OutputText(1, 3, 3, "Welcome %s", PA_UserInfo.Name);// Name
	// Same as the one a bit donw...
	
	// Create the sprites for female and male dancers
	PA_CreateSprite(1, 0,(void*)dancefemaleanim_Sprite, OBJ_SIZE_64X64,1, 0, 112, 118);
	//PA_CreateSprite(0, 1,(void*)cursor_Sprite, OBJ_SIZE_16X32,1, 0, 40, 40);
	
	// Now animate them, on screen 0, speed 20
	PA_StartSpriteAnim(1, 	// Screen
							0, 	// Sprite number
							0, 	// First frame
							31, 	// Last frame
							20); 	// Speed
	//PA_StartSpriteAnim(0, 1, 0, 23, 20); 	
	//PA_PlaySoundEx2(0, gto1, sound_size, 64, 11025, 1, 1, sound_size);						
	// Sets the speed again, unnecesary							
	//PA_SetSpriteAnimSpeed(0,0,20);
	//PA_SetSpriteAnimSpeed(0,1,20); 
	PA_LoadGifXY(0, 127-87, 0, (void*)hentai);
	PA_GifAnimSpeed(3);

	while(1) {
	PA_OutputText(1, 3, 3, "Welcome %s", PA_UserInfo.Name);
	PA_OutputText(1, 4, 16, "%02d/%02d/%02d", PA_RTC.Day, PA_RTC.Month, PA_RTC.Year); // Date
	PA_OutputText(1, 4, 17, "%02d:%02d:%02d" , PA_RTC.Hour, PA_RTC.Minutes, PA_RTC.Seconds); // Time
	PA_OutputText(1, 5, 18,"Mic: %d   ", PA_MicGetVol());
	// Checks the lid to pause app and turn light of
	PA_CheckLid();
	if (PA_MicGetVol() > 100 ){
	PA_LoadGifXY(0, 127-87, 0, (void*)hentai);
	}
	// Waits for VBL before it continues, to limit fps to 60, lol
	PA_WaitForVBL();
	}
	
	return 0;
}
